/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package chapter5.structural.adapter;

/**
 *
 * @author ASUS
 */
public class TemperatureObjectReporter implements TemperatureInfo{
    CelciosReporter celciosReporter;
    
    public TemperatureObjectReporter()
    {
        celciosReporter = new CelciosReporter();
    }

    @Override
    public double getTemperatureInF() {
        return cToF(celciosReporter.getTemperature());
    }

    @Override
    public void setTemperatureInF(double temperatureInF) {
        celciosReporter.setTemperature(cToF(temperatureInF));
    }

    @Override
    public double getTemperatureInC() {
        return celciosReporter.getTemperature();
    }

    @Override
    public void setTemperatureInC(double temperatureInC) {
        celciosReporter.setTemperature(temperatureInC);
    }
    
    private double fToC(double f)
    {
        return ((f - 32)*5/9);
    }
    
    private double cToF(double c)
    {
        return ((c * 9/5)+ 32);
    }
    
}
